gh-148228: Enable error overlays in the REPL#148229
gh-148228: Enable error overlays in the REPL#148229johnslavik wants to merge 5 commits intopython:mainfrom
Conversation
| r.setpos_from_xy(x, new_y) | ||
|
|
||
|
|
||
| class down(MotionCommand): |
There was a problem hiding this comment.
What makes down special? Doesn't the up command has the same UX bug that down ? Don't we need something like
if r.bol() == 0:
if r.historyi > 0:
r.select_item(r.historyi - 1)
return
if r.pos == 0:
r.error("start of buffer")
else:
r.pos = 0
returnfor the up version?
| t = THEME() | ||
| error_prefix = f"{t.error}{error_prefix}{t.reset}" | ||
| self.console.beep() | ||
| self.msg = error_prefix + msg |
There was a problem hiding this comment.
Maybe I am misreading this flow but if I am not wrong, the error() now embeds the escape sequences into self.msg. The message renderer at _render_message_lines slices by string length, not visible width. Then, len(message_line) counts the ANSI bytes (\x1b[1;31m ... \x1b[0m), so on narrow terminals (or long error messages) the slice boundary can land mid-escape, producing a truncated \x1b[ on one line and stray m on the next leaving the whole line un-colored or visually corrupted.
| if r.pos == len(b): | ||
| r.error("end of buffer") | ||
| else: | ||
| r.pos = len(b) |
There was a problem hiding this comment.
Do we have tests that cover both branches here?
Small proof of concept for gh-148228. We can build on this further on.